jQuery(function() {
	/**
	$("#companyEmail").focus(function() {
		jQuery("#companyEmailValidate").attr("class","beforeCheck");
		jQuery("#companyEmail").css("border","1px dotted green");
		$("#companyEmailValidate").html("请输入你公司的邮箱,方便日后找回密码.");

	});

	$("#companyTaxCode").focus(function() {
		jQuery("#companyTaxCodeValidate").attr("class","beforeCheck");
		jQuery("#companyTaxCode").css("border","1px dotted green");
		$("#companyTaxCodeValidate").html("请填入正确的公司税号");

	});

	$("#companyName").focus(function() {
		jQuery("#companyNameValidate").attr("class","beforeCheck");
		jQuery("#companyName").css("border","1px dotted green");
		jQuery("#companyNameValidate").html("请填入正确的公司名称");

	});
	$("#companyCode").focus(function() {
		jQuery("#companyCodeValidate").attr("class","beforeCheck");
		jQuery("#companyCode").css("border","1px dotted green");
		jQuery("#companyCodeValidate").html("请填入合法的构代机码");

	});

	*/
	
	
	
	/**
			jQuery("#userEmail").blur(function() {
				var reg = /^([a-zA-Z0-9._-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/;
				var userEmail = jQuery(this).val();
				if (jQuery.trim(userEmail) == "") {
					
					jQuery("#userEmailValidate").attr("class","ico_16 checkError");
					jQuery("#userEmail").css("border","1px dotted red");
					jQuery("#userEmailValidate").html("邮箱不能为空");

				} else if (!reg.test(userEmail)) {
					jQuery("#userEmailValidate").attr("class","ico_16 checkError");
					jQuery("#userEmail").css("border","1px dotted red");
					jQuery("#userEmailValidate").html("邮箱格式不正确");

				} else {
					jQuery.get("/company/validation!validateCreator.do?userEmail="
									+ userEmail, null, function(data) {		
								jQuery("#userEmailValidate").attr("class","ico_16 checkError");
								jQuery("#userEmail").css("border","1px dotted red");		
								jQuery("#userEmailValidate").html(data);
								
							});
				}
			});*/

	       jQuery("#userEmail").focus();
				
			jQuery("#companyEmail").blur(function() {
				var reg = /^([a-zA-Z0-9._-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/;
				var companyEmail = jQuery(this).val();
				if (jQuery.trim(companyEmail) == "") {
				jQuery("#companyEmailValidate").attr("class","msg error");
				jQuery("#companyEmail").css("border","1px dotted red");
				jQuery("#companyEmailValidate").html("邮箱不能为空");

				} else if (!reg.test(companyEmail)) {
					jQuery("#companyEmailValidate").attr("class","msg error");
					jQuery("#companyEmail").css("border","1px dotted red");
					jQuery("#companyEmailValidate").html("邮箱格式不正确");

				} else {
					jQuery.post(
							formsScritpUrl+"/company/validation!validateCompanyEmail.do?companyEmail="
									+ companyEmail, null, function(data) {



										if ($.trim(data)) {
											jQuery("#companyEmailValidate").attr("class","msg error");
											jQuery("#companyEmail").css("border","1px dotted red");
											jQuery("#companyEmailValidate").html("对不起!该公司Email已经被使用");
										} else {
											jQuery("#companyEmailValidate").attr("class","msg ok");
											jQuery("#companyEmailValidate").html("正确");

										}			
					
							});
				}
			});
			
			jQuery("#companyTaxCode").blur(function() {
				var reg =/(^\d{13}$)|(^\d{15}$)/;
				var companyTaxCode = jQuery(this).val();
				if (jQuery.trim(companyTaxCode) == "") {
					jQuery("#companyTaxCodeValidate").attr("class","msg error");
					jQuery("#companyTaxCode").css("border","1px dotted red");
					jQuery("#companyTaxCodeValidate").html("税号不能为空");

				} else if (!reg.test(companyTaxCode)) {

					jQuery("#companyTaxCodeValidate").attr("class","msg error");
					jQuery("#companyTaxCode").css("border","1px dotted red");				
					jQuery("#companyTaxCodeValidate").html("请输入正确的税号");

				} else {
					jQuery.post(
							formsScritpUrl+"/company/validation!validateCompanyTaxCode.do",{companyTaxCode:jQuery.trim(companyTaxCode)}, function(data) {


										if ($.trim(data)) {
											jQuery("#companyTaxCodeValidate").attr("class","msg error");
											jQuery("#companyTaxCode").css("border","1px dotted red");									
											jQuery("#companyTaxCodeValidate").html("对不起!该公司税号已经被使用");
										} else {
											jQuery("#companyTaxCodeValidate").attr("class","msg ok");
											jQuery("#companyTaxCodeValidate").html("正确");

										}
					
							});
				}
			});
			
			jQuery("#companyName").blur(function() {
				var companyName = jQuery(this).val();
				if (!jQuery.trim(companyName)) {
					
					jQuery("#companyNameValidate").attr("class","msg error");
					jQuery("#companyName").css("border","1px dotted red");
					jQuery("#companyNameValidate").html("公司名称不能为空");

				} else {
					jQuery.post(
							formsScritpUrl+"/company/validation!validateCompanyName.do",{companyName:jQuery.trim(companyName)}, function(data) {


										if ($.trim(data)) {
											jQuery("#companyNameValidate").attr("class","msg error");
											jQuery("#companyName").css("border","1px dotted red");
											jQuery("#companyNameValidate").html("对不起!该公司名称已经被使用");
										} else {
											jQuery("#companyNameValidate").attr("class","msg ok");
											jQuery("#companyNameValidate").html("正确");

										}
							});
				}
			});
			
			jQuery("#companyCode").blur(function() {
				var companyCode = jQuery(this).val();
				if (jQuery.trim(companyCode) == "") {
					jQuery("#companyCodeValidate").attr("class","ico_16 checkError");
					jQuery("#companyCode").css("border","1px dotted red");
					jQuery("#companyCodeValidate").html("机构代码不能为空");
				}else {
					jQuery.post(
							formsScritpUrl+"/company/validation!validateCompanyCode.do",{companyCode:companyCode}, function(data) {
                                   
										if ($.trim(data)) {
											jQuery("#companyCodeValidate").attr("class","msg error");
											jQuery("#companyCode").css("border","1px dotted red");
											jQuery("#companyCodeValidate").html("对不起!该公司机构代码已经被使用");
										} else {
											jQuery("#companyCodeValidate").attr("class","msg ok");
											jQuery("#companyCodeValidate").html("正确");

										}			

							});
				}
			});	
			
			
			
			jQuery("#postcode").blur(function() {
				var reg =/^[1-9]\d{5}(?!\d)$/;
				var postcode = jQuery(this).val();
				if(jQuery.trim(postcode) != ""){
                    if (!reg.test(postcode)) {
					jQuery("#postCodeValidate").attr("class","msg error");
					jQuery("#postcode").css("border","1px dotted red");				
					jQuery("#postCodeValidate").html("请输入正确的邮政编码格式");

				}else{
					
					jQuery("#postCodeValidate").attr("class","msg ok");
					jQuery("#postcode").css("border","1px dotted green");	
					jQuery("#postCodeValidate").html("正确");
					
				} 
                    
				}else{
					jQuery("#postCodeValidate").attr("class","");
					jQuery("#postcode").css("border","1px dotted green");
					jQuery("#postCodeValidate").html("");
					
				}
			});	
			
			
			jQuery("#qq").blur(function() {
				var reg =/^[1-9]{1}\d{4,}$/;
				var qq = jQuery(this).val();
				if(jQuery.trim(qq) != ""){
                    if (!reg.test(qq)) {
					jQuery("#qqValidate").attr("class","msg error");
					jQuery("#qq").css("border","1px dotted red");				
					jQuery("#qqValidate").html("请输入正确的qq格式");

				}else{
				   	
					jQuery("#qqValidate").attr("class","msg ok");
					jQuery("#qq").css("border","1px dotted green");	
					jQuery("#qqValidate").html("正确");
					
				}
                    
				}else{
					jQuery("#qqValidate").attr("class","");
					jQuery("#qq").css("border","1px dotted green");
					jQuery("#qqValidate").html("");
					
				}
			});	
			
			jQuery("#msn").blur(function() {
				var reg =/^([a-zA-Z0-9._-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/;
				var msn = jQuery(this).val();
				
				if(jQuery.trim(msn)){
					
                    if(!reg.test(msn)) {
					jQuery("#msnValidate").attr("class","msg error");
					jQuery("#msn").css("border","1px dotted red");				
					jQuery("#msnValidate").html("请输入正确的msn格式");

				   }
                    else{
    					jQuery("#msnValidate").attr("class","msg ok");
    					jQuery("#msn").css("border","1px dotted green");				
    					jQuery("#msnValidate").html("正确");

    				   }
                    
				}else{
					jQuery("#msnValidate").attr("class","");
					jQuery("#msn").css("border","1px dotted green");
					jQuery("#msnValidate").html("");


			}});
			
			jQuery("#web").blur(function() {
				var reg =/^(http\:\/\/)([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?$/;				
				var web = jQuery(this).val();
				if(jQuery.trim(web) != ""){
                    if (!reg.test(web)) {
					jQuery("#webValidate").attr("class","msg error");
					jQuery("#web").css("border","1px dotted red");				
					jQuery("#webValidate").html("请输入正确的网址格式");

				}else{
					
					jQuery("#webValidate").attr("class","msg ok");
					jQuery("#web").css("border","1px dotted green");	
					jQuery("#webValidate").html("正确");			
					
					
				} 
                    
				}else{
					jQuery("#webValidate").attr("class","");
					jQuery("#web").css("border","1px dotted green");
					jQuery("#webValidate").html("");
					
				}
			});	
	
			
			var  check = function(r){
				
		            return r=="msg error";
		            
		        };
			

			$("#inviteRegister_submitPage").click(
			function(){		
				
			var isemailRequried=check($("#emailRequried").attr("class"));
			var ispasswordRequried = check($("#passwordRequried").attr("class"));
			var ispasswordEqual = check($("#passwordEqual").attr("class"));
			var isidentify = check($("#identify").attr("class"));
			var iscompanyName=check($("#companyNameValidate").attr("class"));
			var ismsnValidate =check($("#msnValidate").attr("class"));
			var iscompanyTaxCodeValidate=check($("#companyTaxCode").attr("class"));
			var iscompanyCodeValidate=check($("#companyCodeValidate").attr("class"));
			var ispostCodeValidate=check($("#postCodeValidate").attr("class"));
			var isqqValidate=check($("#qqValidate").attr("class"));
			var iswebValidate=check($("#webValidate").attr("class"));
		
			var register_check = $("#inviteRegister_checkbox").attr("checked");
			
			if(register_check&&!isemailRequried&&!ispasswordRequried&&!ispasswordEqual&&!isidentify&&!iscompanyName&&!ismsnValidate&&!iscompanyTaxCodeValidate
					&&!iscompanyCodeValidate&&!ispostCodeValidate&&!isqqValidate&&!iswebValidate){
			
				$("#inviteRegesterForm").submit();
				
		    }else{
		    	
		    	alert("请根据提示,按步骤正确进行操作");
		    	
		    }
		  }
			);
			
});